<!--用户管理-->
<template>
  <div class="user-manage">
    <a-card size="small" :headStyle="{ background: '#f9f9f9' }" :bodyStyle="{ height: 'calc(100% - 48px)' }">
      <div slot="title">
        <div class="top-icon">
          <icon-font type="icon-yonghuguanli" />
        </div>
        <span>用户管理</span>
      </div>
      <div slot="extra">
        <a-button type="primary" icon="plus" @click="userClick('add')">新增用户</a-button>
      </div>
      <!-- 用户管理表格 -->
      <el-table
        :data="userTableData"
        highlight-current-row
        border
        height="100%"
        :row-style="{height:'40px'}"
        :cell-style="{padding:'0px'}"
        :header-cell-style="{background: '#FAFAFA', padding: 0, height: '40px', color: '#666666'}"
        style="width: 100%">
        <slot v-for="(item,index) in userColumns">
          <el-table-column
            :key="index"
            :property="item.field"
            :label="item.title"
            :width="item.width"
            show-overflow-tooltip
            sortable>
          </el-table-column>
        </slot>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <a @click="userClick('edit', scope.row)">编辑</a>
            <a-divider type="vertical" />
            <a @click="userClick('del', scope.row)">删除</a>
          </template>
        </el-table-column>
      </el-table>
    </a-card>

    <!-- 用户管理弹出框 -->
    <a-modal
      :maskClosable="false"
      :title="modalTitle"
      v-model="dialogFormVisible"
      @ok="handleOk">
      <a-form
        :label-col="{ span: 6 }"
        :wrapper-col="{ span: 18 }"
        :form="form">
        <a-form-item label="顺序号" >
          <a-input type="number" v-decorator="[ 'U_Order', {rules: [{ required: true, message: '请输入顺序号!' }]} ]" />
        </a-form-item>
        <a-form-item label="用户名">
          <a-input v-decorator="['U_Name', {rules: [{ required: true, message: '请输入用户名!' }]} ]" />
        </a-form-item>
        <a-form-item label="用户密码">
          <a-input v-decorator="['U_Password', {rules: [{ required: true, message: '请输入用户密码!' }]} ]" />
        </a-form-item>
        <a-form-item label="员工名称">
          <a-select v-decorator="[ 'U_CName' ]">
            <a-select-option value="1">张三</a-select-option>
            <a-select-option value="2">李四</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="备注">
          <a-input type="textarea" v-decorator="[ 'U_Remark' ]" />
        </a-form-item>
      </a-form>
    </a-modal>
  </div>
</template>

<script>
export default {
  name: 'UserManage',
  components: {
  },
  data () {
    return {
      userTableData: [{
        U_Order: '1',
        U_Name: 'admin',
        U_Dept: '研发部',
        U_Duty: '软件开发',
        U_CName: '张三',
        U_Remark: '11'
      }, {
        U_Order: '2',
        U_Name: 'test',
        U_Dept: '研发部',
        U_Duty: '软件测试',
        U_CName: '李四',
        U_Remark: '22'
      }, {
        U_Order: '3',
        U_Name: 'aaa',
        U_Dept: '研发部',
        U_Duty: '软件开发',
        U_CName: '王五',
        U_Remark: '33'
      }, {
        U_Order: '4',
        U_Name: 'bbb',
        U_Dept: '研发部',
        U_Duty: '软件测试',
        U_CName: '王麻子',
        U_Remark: '44'
      }],
      userColumns: [{
        title: '顺序号',
        field: 'U_Order'
      }, {
        title: '用户名',
        field: 'U_Name'
      }, {
        title: '所在部门',
        field: 'U_Dept'
      }, {
        title: '担任职务',
        field: 'U_Duty'
      }, {
        title: '员工名称',
        field: 'U_CName'
      }, {
        title: '备注',
        field: 'U_Remark'
      }],
      modalTitle: '',
      dialogFormVisible: false, // 用户管理新增修改弹框默认不显示
      form: this.$form.createForm(this)
    }
  },
  created () {
  },
  mounted () {
  },
  methods: {
    userClick (val) {
      switch (val) {
        case 'add':
          this.modalTitle = '用户新增'
          this.dialogFormVisible = true
          break
        case 'edit':
          this.modalTitle = '用户编辑'
          this.dialogFormVisible = true
          break
        case 'del':
          var this_ = this
          this.$confirm({
            title: '提示',
            content: '此操作将永久删除该文件, 是否继续?',
            okText: '确认',
            cancelText: '取消',
            onOk () {
              this_.$message.success('删除成功')
            }
          })
          break
        default:
          break
      }
    },
    handleOk () {}
  }
}
</script>
<style lang="less" scoped>
.user-manage {
  width: 100%;
  height: 100%;
  padding: 10px 10px 0;
  background: #f0f2f5;
}
</style>
